<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="上海大学开源镜像站，致力于为上大校内提供高质量的开源软件镜像、Linux镜像源服务，帮助校内用户更方便地获取开源软件。本镜像站由上海大学开源社区负责维护">
    <meta name="keywords" content="镜像站,镜像源,Linux,开源,软件源"> 
    <meta name="author" content="SHUOSC">
    <title>上海大学开源镜像站</title>
    <link href="/src/element-ui.css" rel="stylesheet">
    <link href="/src/mirrors.css" rel="stylesheet">
    <link rel="shortcut icon" href="/favicon.ico">
</head>

<body>
    <div id="menu">
        <div class="container">
            <el-menu :default-active="activeIndex" mode="horizontal" >
                <div class="title">上海大学开源镜像站</div>
                <div class="navBar">
                    <el-menu-item index="7"><a href="https://osc.shu.edu.cn">Home</a></el-menu-item>
                    <el-menu-item index="2"><a href="/news">News</a></el-menu-item>
                    <el-menu-item index="3"><a href="/status.html">Status</a></el-menu-item>
                    <el-menu-item index="4"><a href="https://help.shuosc.org">Help</a></el-menu-item>
                    <el-menu-item index="5"><a href="/news/atom.xml">RSS</a></el-menu-item>
                    <el-menu-item index="6"><a href="/">Mirrors</a></el-menu-item>
                </div>
                <div class="clear"></div>
            </el-menu>
        </div>
    </div>
    <div class="container">
        <div id="mirrors-list">
            <div class="bar">
                <div class="title">同步状态</div>
                <div class="list">
                    <div class="content">
                        <template>
                            <el-table :data="searchData" stripe style="width: 100%" v-if="isAll">
                                <el-table-column prop="name" label="镜像名" sortable min-width="20%">
                                    <template scope="scope">
                                        <a v-bind:href="[scope.row.url]">{{scope.row.name}}</a>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="sources" label="上游地址"  min-width="35%"></el-table-column>
                                <el-table-column prop="taskStatus" label="同步状态"  min-width="10%">
                                    <template scope="scope">
                                        <el-tag v-if="scope.row.taskStatus == '1'" type="warning">正在同步</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '0'" type="primary">尚未同步</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '0'" type="success">同步完成</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '1'" type="success">同步完成</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '4'" type="success">同步完成</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '8'" type="success">同步完成</el-tag>
                                        <el-tag v-else type="danger">同步出错</el-tag>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="updateTime" label="最近同步完成时间" sortable min-width="15%">
                                    <template scope="scope">
                                        <div v-if="scope.row.updateTime == ''">Unknow</div>
                                        <div v-else>{{scope.row.updateTime}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="nextTime" label="下次同步时间" sortable min-width="15%">
                                    <template scope="scope">
                                        <div v-if="scope.row.nextTime == ''">Unknow</div>
                                        <div v-else>{{scope.row.nextTime}}</div>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-table :data="searchData" stripe style="width: 1024px;" v-else>
                                <el-table-column prop="name" label="镜像名" sortable min-width="20%">
                                    <template scope="scope">
                                        <a v-bind:href="[scope.row.url]">{{scope.row.name}}</a>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="sources" label="上游地址" min-width="35%"></el-table-column>
                                <el-table-column prop="taskStatus" label="同步状态" min-width="10%">
                                    <template scope="scope">
                                        <el-tag v-if="scope.row.taskStatus == '1'" type="warning">正在同步</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '0'" type="primary">尚未同步</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '0'" type="success">同步完成</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '1'" type="success">同步完成</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '4'" type="success">同步完成</el-tag>
                                        <el-tag v-else-if="scope.row.taskStatus == '2'&&scope.row.exitcode == '8'" type="success">同步完成</el-tag>
                                        <el-tag v-else type="danger">同步出错</el-tag>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="updateTime" label="最近同步完成时间" sortable min-width="15%">
                                    <template scope="scope">
                                        <div v-if="scope.row.updateTime == ''">Unknow</div>
                                        <div v-else>{{scope.row.updateTime}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="nextTime" label="下次同步时间" sortable min-width="15%">
                                    <template scope="scope">
                                        <div v-if="scope.row.nextTime == ''">Unknow</div>
                                        <div v-else>{{scope.row.nextTime}}</div>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </template>
                    </div>
                </div>
            </div>
        </div>
        <div id="servers-status">
            <div class="bar">
                <div class="title">服务器状态</div>
                <div class="graphs">
                    <div class="g-cpu">
                        <iframe src="https://monitor.shuosc.org/dashboard-solo/db/jing-xiang-fu-wu-qi?orgId=1&var-datasource=mirrors&var-group=Linux%20servers&var-host=langchao&var-netif=eth0&panelId=1&theme=light" width="100%" height="300" frameborder="0"></iframe>
                    </div>
                    <div class="g-net">
                        <iframe src="https://monitor.shuosc.org/dashboard-solo/db/jing-xiang-fu-wu-qi?orgId=1&panelId=4&var-datasource=mirrors&var-group=Linux%20servers&var-host=langchao&var-netif=eth0&theme=light" width="100%" height="300" frameborder="0"></iframe>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
        </div>
    </div>
    <div id="copyright">
        <div class="container">
            <div class="content">
                <p>上海大学开源镜像站是由<a href="http://www.its.shu.edu.cn" target="_blank">上海大学信息化办公室</a>提供基础设施支持，由<a href="https://nita.shu.edu.cn" target="_blank">上海大学NITA实验室</a>提供服务器支持，由<a href="https://osc.shu.edu.cn" target="_blank">上海大学开源社区</a>负责管理维护。本站所有源均可通过HTTP、FTP和RSYNC方式访问，RSYNC的访问模块名为源的HTTP子目录名。</p>
                <p>上海大学开源社区（SHU Open Source Community）是由上海大学的开源技术爱好者于 2010 年自主发起成立的非营利性学生组织。上海大学开源社区的宗旨是：面向全校师生传播开源理念、分享技术知识；为上海大学的开源技术爱好者提供公共服务，建立开放友好的技术交流平台；弘扬自由软件精神，培养自由软件社区文化氛围，为开源事业做出贡献。    </p>
            </div>
            <div class="logo">上海大学开源社区</div>
            <div class="clear"></div>
        </div>
    </div>
    <script src="/src/vue.min.js"></script>
    <script src="/src/element-ui.js"></script>
    <script src="/src/axios.js"></script>
    <script src="/src/mirrors.js"></script>
    <script>
        
        var menu = new Vue({
            el: '#menu',
            data: {
                activeIndex: '1'
            }
        })

        var mirrors = new Vue({
            el: '#mirrors-list',
            data: {
                search: '',
                items: [],
                isAll: 'true'
            },
            created: function() {
                this.loadMirrors();
            },
            methods: {
                loadMirrors: function () {
                    axios.get('/data/mirrors.json')
                    .then(function (response) {
                        mirrors.items = response.data.mirrors;
                    });
                    axios.get('/status/task_status.json')
                    .then(function (response) {
                        for(item of mirrors.items){
                            var name = item.name;
                            var data = response.data[name];
                            var date = new Date();
                            if(date.getHours()>=2){
                                item.updateTime = showTime(0)+" 02:00:00";
                                item.nextTime = showTime(+1)+" 02:00:00";
                            }else{
                                item.updateTime = showTime(-1)+" 02:00:00";
                                item.nextTime = showTime(0)+" 02:00:00";
                            }
                            item.taskStatus = "2";
                            item.exitcode = "0";
                            if(typeof(data['upstream']) != "undefined"){
                                item.sources = data['upstream'];
                            }
                        }
                    });
                    var clientWidth = document.documentElement.clientWidth;
                    if(clientWidth<=768){
                        this.isAll = false;
                    }
                }
            },
            computed: {
                searchData: function() {
                    var search = this.search;
                    var vm = this;
                    if (search) {
                        return this.items.filter(function(item) {
                            return Object.keys(item).some(function(key) {
                                return String(item[key]).toLowerCase().indexOf(search) > -1
                            })
                        })
                    }
                    vm.items = vm.items.sort(function(x, y) {
                        return x.name.localeCompare(y.name);
                    });
                    return vm.items;
                }
            }
        })

    </script>

</body>
</html>
